<?php
	include("../include/init.php");//将配置文件全部加载进来
	include("../include/check_login.php");//登录

	$insert = new sql_class("product");

	if($_POST){
		$data = array(
					"product_name"=>$_POST['product_name'],
					"product_price"=>$_POST['product_price'],
					"product_disc"=>$_POST['product_disc'],
					"product_time"=>strtotime($_POST['product_time']),
					"product_date"=>$_POST['product_date'],
					"product_promise"=>$_POST['product_promise'],
					"product_address"=>$_POST['product_address'],
					"product_desc"=>$_POST['product_desc'],
					"product_content"=>$_POST['product_content'],
				);
		
		if($_FILES['product_img']['size'] > 0 ){
			$path = DIR."/uploads/";
			$filename = uploads("product_img",1048576,$path);
			$data['product_img'] = "uploads/".$filename;
		}

		$insert_id = $insert->save($data);
		if($insert_id){
			show_msg("添加产品成功","pro_list.php");
			exit;
		}else{
			show_msg("添加产品失败","pro_add.php");
			exit;
		}
	}
	


	$smarty->display("admin/pro_add.html");//连接index.html



?>